'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:PersonnelAjdjCtrl
 * @description
 * # PersonnelAjdjCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
  .controller('PersonnelAjdjCtrl', function ($scope, openApi, DataService, Util, $routeParams, FormSubmit) {
    var id = $scope.process_id = $routeParams.id
    $scope.submit = function (operationId) {

      // 底部类型end
      var options = {};
      // 流程id
      options.id = id;
      // 根据operationId判断是草稿还是提交
      options.operationId = operationId;
      options.urlParam = openApi.caseRegister;
      options.param = angular.copy($scope.param, {});
      FormSubmit.submit(options, $scope);
    };

    $scope.showType = function () {
      var param = {}
      param.type = "案件登记类型";
      DataService.getData(openApi.getKeyType, param).then(function (data) {
        $scope.typeList = data
      })
    };
    $scope.validate = function () {
      if (!$scope.param.caseType) {
        Util.Toast("请选择案件登记类型");
        return;
      }
      if (!$scope.param.receiveCaseDate) {
        Util.Toast("请选择案件接收日期");
        return;
      }
      if (!$scope.param.caseCity) {
        Util.Toast("请填写案发城市");
        return;
      }

      if (!$scope.param.caseDesc) {
        Util.Toast("请填写案件描述");
        return;
      }
      if (!$scope.param.filePath) {
        Util.Toast("请添加附件");
        return;
      }
      if (!$scope.validation.passvalidation) {
        Util.Toast($scope.validation.tip);
        return;
      }
      return true;
    }
    var init = function () {
      // 获取回显的详细信息
      Util.getDetailData(id, function (data) {
        $scope.param = data;
      });
      $scope.showType()
    };
    // 初始化
    init();

  });
